package cn.wfmiss.spring6.iocxml.bean;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: wfmiss
 * @Date: 2023/12/31/11:05
 * @Description:
 */
public class TestUser {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        // 1 根据id获取Bean
        // User user1= (User) context.getBean("user");
        // System.out.println("根据id获取Bean:"+user1);

        // 2 根据类型获取Bean
        // ！！！当更具类型获取bean时，要求IOC容器中指定类型的bean有且只有能一个
        User user2 = context.getBean(User.class);
        System.out.println("根据类型获取Bean:"+user2);

        // 3 根据id和类型获取Bean
        // User user3 = context.getBean("user", User.class);
        // System.out.println("根据id和类型获取Bean:"+user3);


    }
}
